
import 'package:flutter/material.dart';

void main() =>runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context){
    return MaterialApp(
        home:HYHomePage()
    );
  }
}

class HYHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context){
    return Scaffold(
      appBar: AppBar(
        title: Text("基础widget"),
      ),
      body:HYHomeContent(),
    );
  }
}

class HYHomeContent extends StatefulWidget {
  const HYHomeContent({super.key});

  @override
  State<HYHomeContent> createState() => _HYHomeContentState();
}

class _HYHomeContentState extends State<HYHomeContent> {
  @override
  Widget build(BuildContext context) {
    // return const Text(
    //   "最近天津贫困学生，助学金被侵占的事情，闹得沸沸扬扬，不断地反转再反转，看的人眼花缭乱。",
    //   textAlign: TextAlign.center,
    //   maxLines: 2,
    //   overflow: TextOverflow.ellipsis,
    //   style: TextStyle(
    //       fontSize: 30,
    //       color: Colors.red,
    //       fontWeight: FontWeight.bold
    //   ),
    // );
   return TextRichDemo();

  }
  //CMD + option + M 将选中代码提取到某个方法中
  Text TextRichDemo() {
    return const Text.rich(
    TextSpan(
      text: 'Hello', // default text style
      style: TextStyle(color: Colors.red),
      children: [
        TextSpan(text: ' beautiful ', style: TextStyle(fontStyle: FontStyle.italic)),
        TextSpan(text: 'world', style: TextStyle(fontWeight: FontWeight.bold)),
        WidgetSpan(child: Icon(Icons.ice_skating))
        //WidgetSpan(child: Icon(Icons.add,color:Colors.green,))

      ],
    ),
  );
  }
}
